package org.apache.dolphinscheduler.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.dolphinscheduler.dao.entity.RelationRole;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author denggh
 * @since 2023-11-13
 */
public interface RelationRoleMapper extends BaseMapper<RelationRole> {

    /**
     * delete project user relation
     *
     * @param targetId targetId
     * @param roleId   roleId
     * @return delete result
     */
    int deleteRelation(@Param("targetId") int targetId, @Param("roleId") int roleId, @Param("targetType") String targetType);

    /**
     * query  relation
     *
     * @param targetId targetId
     * @param roleId   roleId
     * @param perm   perm
     * @return role relation
     */
    RelationRole queryRelation(@Param("targetId") int targetId, @Param("roleId") int roleId, @Param("targetType") String targetType, @Param("perm") int perm);

    /**
     * query  relation list
     *
     * @param targetType targetType
     * @param roleId   roleId
     * @param perm   perm
     * @return role relation
     */
    List<RelationRole> queryRelationList(@Param("roleId") int roleId, @Param("targetType") String targetType, @Param("perm") int perm);

    Integer existsResourceByRoleId(@Param("roleId") int roleId,@Param("targetId") int targetId);
}
